<?php
namespace app\index\controller;

use app\index\BaseController;
use think\Controller;

use app\admin\model\ImageModel;

use app\admin\model\NewsModel;

class Index extends BaseController
{
    public function index()
    {
        $res = ImageModel::where('type',1)
            ->whereOr('type',3)
            ->select();

        $newImgList = [];
        $heroImgList = [];
        foreach ($res as $value){

            $type = $value->getData('type');
            if($type == '1'){
                $newImgList[] = $value->img_path;
            }

            if($type == '3'){
                $heroImgList[] = $value->img_path;
            }

        }

        $this->assign('newImgList',$newImgList);
        $this->assign('heroImgList',$heroImgList);

        $zx =  NewsModel::order('create_time', 'desc')->limit(5)->select();
        $gg =  NewsModel::where('type','公告')->order('create_time', 'desc')->limit(5)->select();
        $gl =  NewsModel::where('type','攻略')->order('create_time', 'desc')->limit(5)->select();

        $hd =  NewsModel::where('type','活动')->order('create_time', 'desc')->limit(5)->select();
        $bl =  NewsModel::where('type','爆料')->order('create_time', 'desc')->limit(5)->select();


        $this->assign('zx',$zx);
        $this->assign('gg',$gg);
        $this->assign('gl',$gl);
        $this->assign('hd',$hd);
        $this->assign('bl',$bl);

        return $this->fetch();
    }


    public function hello($name = 'ThinkPHP5')
    {
        return 'hello,' . $name;
    }
}
